<template>
  <span />
</template>

<script>
import hotkeys from 'hotkeys-js'
import { mapMutations, mapState } from 'vuex'

export default {
  name: 'HotkeyManager',
  computed: {
    ...mapState(['current']),
  },
  mounted() {
    this.reg()
  },
  methods: {
    ...mapMutations(['currentComponent', 'removeComponent']),
    reg() {
      hotkeys('*', (event) => {
        event.preventDefault()
      })
      this.save()
      this.delete()
    },
    save() {
      hotkeys('ctrl+s', () => {
        // event.preventDefault()
        console.log('=======saving')
      })
    },
    delete() {
      hotkeys('del', () => {
        if (this.current) {
          this.removeComponent(this.current)
        }
      })
    },
  },
}
</script>

<style scoped></style>
